package com.shuoyue.ycgk.views.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;


import com.shuoyue.ycgk.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * 更多Dialog
 * Created by Forty'7 on 2019/8/17
 */

public class TextSizeDialog extends Dialog {
    @BindView(R.id.wrong)
    TextView wrong;
    @BindView(R.id.tf1)
    TextView tf1;
    @BindView(R.id.tf2)
    TextView tf2;
    @BindView(R.id.tf3)
    TextView tf3;
    private Context mContext;

    public TextSizeDialog(@NonNull Context context) {
        super(context, R.style.dialog);
        this.mContext = context;
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialog_textsize);
        ButterKnife.bind(this);

        getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        getWindow().setGravity(Gravity.TOP | Gravity.RIGHT);
    }

    Onclick callback;


    public void setCallback(Onclick callback) {
        this.callback = callback;
    }

    @OnClick({R.id.wrong, R.id.tf1, R.id.tf2, R.id.tf3})
    public void onViewClicked(View view) {
        hide();

        if (callback == null) {
            return;
        }
        switch (view.getId()) {
            case R.id.wrong:
                callback.wrong();
                break;
            case R.id.tf1:

                callback.textf(18);
                tf1.setTextColor(ContextCompat.getColor(mContext, R.color.all_orange_color));
                tf2.setTextColor(ContextCompat.getColor(mContext, R.color.white));
                tf3.setTextColor(ContextCompat.getColor(mContext, R.color.white));

                break;
            case R.id.tf2:
                callback.textf(19);
                tf1.setTextColor(ContextCompat.getColor(mContext, R.color.white));
                tf2.setTextColor(ContextCompat.getColor(mContext, R.color.all_orange_color));
                tf3.setTextColor(ContextCompat.getColor(mContext, R.color.white));
                break;
            case R.id.tf3:
                callback.textf(20);
                tf1.setTextColor(ContextCompat.getColor(mContext, R.color.white));
                tf2.setTextColor(ContextCompat.getColor(mContext, R.color.white));
                tf3.setTextColor(ContextCompat.getColor(mContext, R.color.all_orange_color));
                break;
        }
    }

    public interface Onclick {

        void wrong();

        void textf(int textSize);

    }
}
